<template lang="html">
  <div class="c_coupon_item" @click="goBuy">
    <div class="coupon_tag"><em>{{item.product_unit_price}}</em> <span>元会员活动礼包</span></div>
    <div class="coupon_info">
      <img class="coupon_img" :src="item.product_image" alt="">
      <div class="coupon_des">
        <div class="song"></div>
        <div class="money">
          <div class="money_num">
            <em>¥</em>{{parseFloat(item.coupon_total)}}
          </div>
          <div class="money_type">{{item.coupon_type}}</div>
        </div>
      </div>
      <div class="coupon_tips"><b>礼包内含：</b>{{item.gift_have}}</div>
    </div>
    <div class="buttom"><span :class="is_vip ? 'vip' : 'no_vip'">{{is_vip ? parseFloat(item.discount) ? '邀请好友 返利¥' + item.discount : '邀请好友' : '开通会员'}}</span></div>
  </div>
</template>

<script>
import Tool from '@/utils/tool.js'
import Path from '@/utils/path.js'
// import  'vue-circle-progress/dist/circle-progress.css'
export default {
  props: ['item', 'user_info'],
  data () {
    return {
      is_show: false,
      is_received: false,
      is_vip: false
    }
  },
  created () {
    if (this.user_info && this.user_info.lev_code === 'COMMON_USER') {
      this.is_vip = false
    } else if (this.user_info.lev_code !== 'COMMON_USER') {
      this.is_vip = true
    }
  },
  methods: {
    goUsed () {
      let isClient = Tool.isClient()
      if (isClient) {
        window.location = 'yggback://'
      } else {
        window.location = Path() + '/'
      }
    },
    showRule () {
      this.is_show = !this.is_show
    },
    goBuy () {
      let isMini = sessionStorage.getItem('isMini')
      let item = this.item
      let params = '?pid=' + item.product_id + '&item_id=' + item.default_item_id
      if (isMini) {
        if (this.is_vip) {
          window.wx.miniProgram.navigateTo({ url: '/pages/giftbagDetails/giftbagDetails' + params })
        } else {
          window.wx.miniProgram.navigateTo({ url: '/pages/shopDetails/shopDetails' + params })
        }
      } else {
        if (this.is_vip) {
          this.$router.push('/main/giftbagDetails' + params)
        } else {
          this.$router.push('/main/shopDetails' + params)
        }
      }
    },
    getCoupon (id, unreceived) {
      if (unreceived) {
        var data = {
          activity_id: id
        }
        return new Promise((resolve, reject) => {
          this.$Axios({ url: 'shop_user_voucher', data, method: 'post' }).then((resp) => { // 请求成功
            if (resp.return_code === '0000') {
              this.is_received = true
              this.$toast('领取成功！')
            } else {
              this.$toast(resp.return_msg)
            }
            resolve(resp)
          }).catch((error) => { // 请求失败
            this.$_requestInterceptor('error', error)
            reject(error)
          })
        })
      } else {
        this.$toast('去首页看看')
      }
    }
  }
}
</script>

<style lang="css" scoped>
</style>
